package com.nf.service;

import com.nf.entity.Message;
import com.nf.entity.Student;
import com.nf.mapper.TestMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

@Service
public class TestServiceImpl implements TestService{

    @Autowired
    @Qualifier("testMapperImpl2")
    private TestMapper testMapper;

    @Override
    public Message getMessage(){
        Student student = testMapper.getStudent();

        Message message = new Message();
        if (student == null){
            message.setCode(500);
            message.setInfo("服务器失败");
            return message;
        }
        if (  student.getName().equals("小明")  ){
            message.setCode(200);
            message.setInfo("这是老板儿子,录用");
            return message;
        }
        if ( student.getAge()<18){
            message.setCode(500);
            message.setInfo("不予录用，公司不招童工");
        }else {
            message.setCode(200);
            message.setInfo("够18岁，有手有脚,录用");
        }

        return message;
    }
}
